package com.ruoyi.statistic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistic.domain.WDayReportStat;
import com.ruoyi.statistic.service.IWDayReportStatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日统计表Controller
 * 
 * @author wzy
 * @date 2024-10-17 16:25:05
 */
@RestController
@RequestMapping("/statistic/dayreport")
public class WDayReportStatController extends BaseController
{
    @Autowired
    private IWDayReportStatService wDayReportStatService;

    /**
     * 查询日统计表列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayreport:list')")
    @GetMapping("/list")
    public TableDataInfo list(WDayReportStat wDayReportStat)
    {
        startPage();
        List<WDayReportStat> list = wDayReportStatService.selectWDayReportStatList(wDayReportStat);
        return getDataTable(list);
    }

    /**
     * 导出日统计表列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayreport:export')")
    @Log(title = "日统计表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WDayReportStat wDayReportStat)
    {
        List<WDayReportStat> list = wDayReportStatService.selectWDayReportStatList(wDayReportStat);
        ExcelUtil<WDayReportStat> util = new ExcelUtil<WDayReportStat>(WDayReportStat.class);
        util.exportExcel(response, list, "日统计表数据");
    }

    /**
     * 获取日统计表详细信息
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayreport:query')")
    @GetMapping(value = "/{dayReportStatisticId}")
    public AjaxResult getInfo(@PathVariable("dayReportStatisticId") Long dayReportStatisticId)
    {
        return success(wDayReportStatService.selectWDayReportStatByDayReportStatisticId(dayReportStatisticId));
    }

    /**
     * 新增日统计表
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayreport:add')")
    @Log(title = "日统计表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WDayReportStat wDayReportStat)
    {
        wDayReportStat.setCreateBy(getNickName());
        return toAjax(wDayReportStatService.insertWDayReportStat(wDayReportStat));
    }

    /**
     * 修改日统计表
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayreport:edit')")
    @Log(title = "日统计表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WDayReportStat wDayReportStat)
    {
        wDayReportStat.setUpdateBy(getNickName());
        return toAjax(wDayReportStatService.updateWDayReportStat(wDayReportStat));
    }

    /**
     * 删除日统计表
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayreport:remove')")
    @Log(title = "日统计表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dayReportStatisticIds}")
    public AjaxResult remove(@PathVariable Long[] dayReportStatisticIds)
    {
        return toAjax(wDayReportStatService.deleteWDayReportStatByDayReportStatisticIds(dayReportStatisticIds));
    }
}
